﻿CREATE FUNCTION [dbo].[getPUPaySumRub]
	(
	@PUId int
	)
RETURNS money
AS
	BEGIN

	DECLARE @paySum money

	SELECT @paySum = SUM(SUM_RUB) from PAYMENT_IN_ITEM WHERE PRODUCT_UNIT_ID=@PUId

	RETURN ISNULL(@paySum,0)
	END